/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.business.customer.core.service.processor.update;

import cn.hutool.core.util.ObjectUtil;
import info.peigen.hotpot.business.customer.core.domain.Customer;
import info.peigen.hotpot.business.customer.core.domain.action.CustomerConverter;
import info.peigen.hotpot.business.customer.core.service.processor.base.AbstractCustomerServiceProcessor;
import info.peigen.hotpot.business.customer.facade.result.register.CustomerUpdateResult;
import info.peigen.hotpot.common.service.base.processor.Processor;
import info.peigen.hotpot.common.service.base.processor.ProcessorServiceContext;
import org.noear.solon.annotation.Component;

/**
 * <b>(CustomerUpdateResultProcessor)</b>
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2023/8/30
 */
@Component
public class CustomerUpdateResultProcessor extends AbstractCustomerServiceProcessor implements Processor {
    @Override
    public Integer level() {
        return 99;
    }

    @Override
    public void execute(ProcessorServiceContext serviceContext) {
        Customer customer = (Customer) serviceContext.getDomain();
        if (ObjectUtil.isNotNull(customer)) {
            CustomerUpdateResult result = (CustomerUpdateResult) serviceContext.getResult();
            result.fromSuccess(CustomerConverter.convertCustomerInfo(customer));
        }
    }

}
